{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
.layui-textarea {
	height: auto!important;
	line-height: 2;
	font-size: 1rem;
}
</style>
<form class="layui-form p-4">
	<h3 class="pb-3">添加章节</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray">章节名称</td>
			<td>
				<div class="layui-form-item" style="margin-bottom: 0;">
					<label class="layui-form-label">{$chapstitle}</label>
					<div class="layui-input-block">
						<input type="text" name="title" lay-reqText="请输入章节名称" value="" autocomplete="off" placeholder="请输入章节名称" class="layui-input">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">章节内容</td>
			<td>
				<textarea name="content" rows="30" class="layui-textarea"></textarea>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray">状态</td>
			<td>
				<input type="radio" name="status" value="1" title="正常" checked>
				<input type="radio" name="status" value="0" title="下架">
			</td>
		</tr>
	</table>
	<div class="py-3">
		<input type="hidden" name="bookid" value="{$book['id']}"/>
		<input type="hidden" name="authorid" value="{$book['authorid']}"/>
		<input type="hidden" name="serial" value="{$serial}"/>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	var moduleInit = ['tool'];

	function feiniaoInit() {
		var form = layui.form, tool = layui.tool;				
		//监听提交
		form.on('submit(webform)', function (data) {			
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("{:url('chapter/add')}", data.field, callback);
			return false;
		});
	}
</script>
{/block}
<!-- /脚本 -->